<template>
  <div @click="store.commit('add')">counter: {{ $store.state.counter }}</div>
  <div>doubleCounter: {{ doubleCounter }}</div>
</template>

<script lang="ts" setup>
import { computed, ref, defineProps } from 'vue'
import { useStore } from 'vuex'
import { key } from '../store'
// 3.传递 InjectionKey 给 useStore
const store = useStore(key)
const counter = computed(() => store.state.counter)
const doubleCounter = computed(() => counter.value * 2)
</script>

<style></style>